package springcloud.controller;


import org.springframework.beans.factory.annotation.Value;
import org.springframework.web.bind.annotation.*;
import springcloud.pojo.Address;

/**
 * @Author 咕唧
 * @Date 2022/6/23 17:07
 * @Version 1.0
 */
@RestController
@RequestMapping("/address")
public class AddressController {

    @Value("${server.port}")
    private int port;

    @GetMapping("/info/{id}")
    public Address findById(@PathVariable Long id) {
        Address address = new Address();
        address.setId(id);
        address.setAddressName("沙阳路一通小区-->" + id + "-->" + port);
        address.setPhoneNum("14874874874==>" + id + "-->" + port);
        return address;

    }

    @GetMapping("/test/{id}")
    public Address test(@PathVariable Long id) {
        Address address = new Address();
        address.setId(id);
        address.setAddressName("这是测试的数据-->" + id + "-->" + port);
        address.setPhoneNum("测试手机号147==>" + id + "-->" + port);
        return address;
    }

    @GetMapping("/test2")
    public String test2(String name) {
        return "test2====>" + name;
    }

    @GetMapping("/test3")
    public String test3(String name, int age) {
        return "test3====>" + name + "====>age---->" + age;
    }

    @PostMapping("/test4")
    public Address test4(@RequestBody Address address) {
        address.setAddressName("这是test4设置的地址");
        return address;
    }
}
